package com.cat.greedyAlgorithm;

import java.io.PrintWriter;
import java.util.PriorityQueue;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/maximum-score-from-removing-stones/
 * @create 2025/10/12 14:28
 * @since JDK17
 */

public class Solution81 {
    public int maximumScore(int a, int b, int c) {
        PriorityQueue<Integer> heap = new PriorityQueue<>((i, j) -> j - i);
        heap.add(a);
        heap.add(b);
        heap.add(c);
        int x, y, ans = 0;
        while (heap.size() > 1) {
            x = heap.poll() - 1;
            y = heap.poll() - 1;
            if (x != 0) {
                heap.add(x);
            }
            if (y != 0) {
                heap.add(y);
            }
            ans++;
        }

        return ans;
    }
}
